package org.bapoint.bawirelessprogressusercenter.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import jakarta.annotation.Resource;
import org.bapoint.bawirelessprogressusercenter.entity.enums.HttpStatusEnum;
import org.bapoint.bawirelessprogressusercenter.service.GetFromDbService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName FirstWirelessProgressController
 * @Description TODO
 * @Author 王逸攀
 * @Date 2025/9/5 16:45
 * @Version 1.0
 */
@RestController
@RequestMapping("/userCenter")
public class FirstWirelessProgressController extends RestBase {


    @Resource
    private GetFromDbService getFromDbService;


    @GetMapping("/firstApi")
    public Object firstApi() {
        List<String> arr = new ArrayList<>();
        arr.add("first");
        arr.add("second");
        arr.add("third");
        arr.add("fourth");
        Map<String, Object> result = new HashMap<>() {
        };
        result.put("list", arr);
        return ajaxSuccess(result, HttpStatusEnum.OK, "操作成功！");
    }

    @GetMapping("/getFromDb")
    public Object getFromDb() throws JsonProcessingException {
        List<Map<String, Object>> list = getFromDbService.getRedisDb();
        return ajaxSuccess(list, HttpStatusEnum.OK, "查询成功！");
    }
}
